#!/bin/bash

read -p "输入你的名字: " name
read -p "输入端口（不要和别人重复）: " port

mkdir code-server
cd code-server
cat > docker-compose.yml <<EOF
services:
    code-server:
        image: registry.intsig.net/cs_hw/code-server:go
        container_name: $name
        ports:
            - "$port:8080"
        volumes:
            - ./projects:/home/coder
            - ./.config:/root/.config
            - ./.local:/root/.local
        cap_add:
            - SYS_PTRACE
        security_opt:
            - seccomp=unconfined
EOF

echo "COMPOSE_PROJECT_NAME=$name" >.env
sudo docker compose up -d
echo "等待容器创建 ....."
sleep 3
echo "已完成容器创建，你的code-server专属密码（password）: "
cat .config/code-server/config.yaml